package com.example.mypotiota_si.Activity;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.mypotiota_si.R;

public class DengLuActivity extends AppCompatActivity {
    private EditText sr_zh,sr_mm;
    private TextView dj_wj,dj_zc;
    private Button dj_dl;
    private CheckBox dj_jz;
    LinearLayout dj_school;

//    int number_school=99;
//    String TAG="DengLuActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_deng_lu);
        //隐藏标题栏
        ActionBar actionBar=getSupportActionBar();
        if (actionBar!=null){
            actionBar.hide();
        }
        //找到控件
        initControl();
        //点击监听
        initMonitor();
    }

    //点击监听
    private void initMonitor() {
        //点击学校
        dj_school.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(DengLuActivity.this,ShouYe_SchoolActivity.class);
                startActivity(intent);
            }
        });
        //点击登录
        dj_dl.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //获取账号密码
                String acc=sr_zh.getText().toString().trim();
                String pass=sr_mm.getText().toString().trim();
                iFpassAndAcc(acc,pass);
                Intent intent=new Intent(DengLuActivity.this,MainActivity.class);
                startActivity(intent);
            }
        });

        //点击忘记密码
        dj_wj.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(DengLuActivity.this,WangJiActivity.class);
                startActivity(intent);

            }
        });
        //更改密码
        dj_zc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(DengLuActivity.this, GengGaiActivity.class);
                startActivity(intent);
            }
        });
        dj_jz.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                //选中
                if (isChecked){

                }
                //没选中
                else {

                }
            }
        });
    }

    private void iFpassAndAcc(String acc, String pass) {
        if(acc.equals("")){
        }


//        User user=new User();
//        user.setUsername(acc);
//        user.setPassword(pass);
//        user.login(new SaveListener<User>() {
//            @Override
//            public void done(User user, BmobException e) {
//                if(e==null){
//                    Toast.makeText(DengLuActivity.this, "dengluchenggong", Toast.LENGTH_SHORT).show();
//                }else{
//                    Toast.makeText(DengLuActivity.this, "登陆失败", Toast.LENGTH_SHORT).show();
//                }
//            }
//        });
    }

    //找到控件
    private void initControl() {
        sr_zh=findViewById(R.id.input_sr_zh);
        sr_mm=findViewById(R.id.input_sr_mm);
        dj_dl=findViewById(R.id.input_dj_dl);
        dj_wj=findViewById(R.id.input_dj_wj);
        dj_zc=findViewById(R.id.input_dj_zc);
        dj_jz=findViewById(R.id.input_dj_jz);
        dj_school=findViewById(R.id.xz_school);
    }
}
